cordova.define("cordova-plugin-android-permissions.Permissions", function(require, exports, module) {
var permissionsName = 'Permissions';

function Permissions() {
    // 位置权限
    this.ACCESS_COARSE_LOCATION = 'ohos.permission.LOCATION';
    this.ACCESS_FINE_LOCATION = 'ohos.permission.LOCATION';
    this.ACCESS_LOCATION_EXTRA_COMMANDS = 'ohos.permission.LOCATION'; // 鸿蒙中合并到位置权限

    // 网络权限
    this.ACCESS_NETWORK_STATE = 'ohos.permission.GET_NETWORK_INFO';
    this.ACCESS_WIFI_STATE = 'ohos.permission.GET_WIFI_INFO';
    this.CHANGE_NETWORK_STATE = 'ohos.permission.SET_NETWORK_INFO';
    this.CHANGE_WIFI_STATE = 'ohos.permission.MANAGE_WIFI_CONNECTION';
    this.CHANGE_WIFI_MULTICAST_STATE = 'ohos.permission.MANAGE_WIFI_CONNECTION'; // 鸿蒙中合并到WiFi管理

    // 相机和麦克风
    this.CAMERA = 'ohos.permission.CAMERA';
    this.RECORD_AUDIO = 'ohos.permission.MICROPHONE';

    // 存储权限
    this.READ_EXTERNAL_STORAGE = 'ohos.permission.READ_USER_STORAGE';
    this.WRITE_EXTERNAL_STORAGE = 'ohos.permission.WRITE_USER_STORAGE';

    // 联系人权限
    this.READ_CONTACTS = 'ohos.permission.READ_CONTACTS';
    this.WRITE_CONTACTS = 'ohos.permission.WRITE_CONTACTS';

    // 日历权限
    this.READ_CALENDAR = 'ohos.permission.READ_CALENDAR';
    this.WRITE_CALENDAR = 'ohos.permission.WRITE_CALENDAR';

    // 电话权限
    this.READ_PHONE_STATE = 'ohos.permission.GET_TELEPHONY_STATE';
    this.CALL_PHONE = 'ohos.permission.PLACE_CALL';
    this.READ_CALL_LOG = 'ohos.permission.READ_CALL_LOG';
    this.WRITE_CALL_LOG = 'ohos.permission.WRITE_CALL_LOG';
    this.PROCESS_OUTGOING_CALLS = 'ohos.permission.PLACE_CALL'; // 鸿蒙中合并到拨号权限

    // 传感器权限
    this.BODY_SENSORS = 'ohos.permission.HEALTH_DATA';

    // 短信权限
    this.READ_SMS = 'ohos.permission.RECEIVE_SMS';
    this.SEND_SMS = 'ohos.permission.SEND_MESSAGES';
    this.RECEIVE_SMS = 'ohos.permission.RECEIVE_SMS';
    this.RECEIVE_MMS = 'ohos.permission.RECEIVE_MMS';

    // 系统权限
    this.INTERNET = 'ohos.permission.INTERNET';
    this.BLUETOOTH = 'ohos.permission.MANAGE_BLUETOOTH';
    this.BLUETOOTH_ADMIN = 'ohos.permission.MANAGE_BLUETOOTH';
    this.NFC = 'ohos.permission.NFC';
    this.VIBRATE = 'ohos.permission.VIBRATE';
    this.WAKE_LOCK = 'ohos.permission.KEEP_BACKGROUND_RUNNING';

    // 账户权限
    this.GET_ACCOUNTS = 'ohos.permission.READ_ACCOUNTS';
    this.MANAGE_ACCOUNTS = 'ohos.permission.MANAGE_ACCOUNTS';
    this.AUTHENTICATE_ACCOUNTS = 'ohos.permission.ACCOUNT_AUTH'; // 鸿蒙中为账户认证权限

    // 以下权限在鸿蒙中不存在或需要特殊处理
    this.ACCESS_CHECKIN_PROPERTIES = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中无此权限
    this.ACCESS_MOCK_LOCATION = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中不支持模拟位置
    this.ACCESS_SURFACE_FLINGER = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中无此底层权限
    this.ACCOUNT_MANAGER = 'ohos.permission.MANAGE_ACCOUNTS'; // 合并到账户管理
    this.ADD_VOICEMAIL = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中无语音邮件功能
    this.BATTERY_STATS = 'ohos.permission.BATTERY_STATS'; // 电池统计权限
    this.BIND_ACCESSIBILITY_SERVICE = 'ohos.permission.ACCESS_ACCESSIBILITY'; // 无障碍服务
    this.BIND_DEVICE_ADMIN = 'ohos.permission.MANAGE_DEVICE_ADMIN'; // 设备管理
    this.BIND_VPN_SERVICE = 'ohos.permission.MANAGE_VPN'; // VPN管理
    this.BLUETOOTH_PRIVILEGED = 'ohos.permission.MANAGE_BLUETOOTH'; // 合并到蓝牙管理
    this.BRICK = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中无此危险权限
    this.CAPTURE_AUDIO_OUTPUT = 'ohos.permission.MICROPHONE'; // 合并到麦克风权限
    this.CAPTURE_VIDEO_OUTPUT = 'ohos.permission.CAMERA'; // 合并到相机权限
    this.CLEAR_APP_CACHE = 'ohos.permission.CLEAN_APPLICATION_DATA'; // 清理应用数据
    this.DELETE_PACKAGES = 'ohos.permission.INSTALL_BUNDLE'; // 安装卸载权限
    this.DISABLE_KEYGUARD = 'ohos.permission.MANAGE_SECURE_SETTINGS'; // 安全管理
    this.EXPAND_STATUS_BAR = 'ohos.permission.SYSTEM_FLOAT_WINDOW'; // 悬浮窗权限
    this.FACTORY_TEST = 'NOT_AVAILABLE_IN_HARMONYOS'; // 工厂测试权限
    this.GET_TASKS = 'ohos.permission.GET_RUNNING_INFO'; // 获取运行信息
    this.INSTALL_PACKAGES = 'ohos.permission.INSTALL_BUNDLE'; // 安装应用
    this.KILL_BACKGROUND_PROCESSES = 'ohos.permission.CLEAN_BACKGROUND_PROCESSES'; // 清理后台进程
    this.MODIFY_AUDIO_SETTINGS = 'ohos.permission.MODIFY_AUDIO_SETTINGS';
    this.MODIFY_PHONE_STATE = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中不允许修改电话状态
    this.MOUNT_UNMOUNT_FILESYSTEMS = 'ohos.permission.MOUNT_UNMOUNT_MANAGER';
    this.READ_LOGS = 'ohos.permission.READ_LOGS';
    this.READ_PROFILE = 'ohos.permission.READ_CONTACTS'; // 合并到联系人权限
    this.REBOOT = 'ohos.permission.REBOOT';
    this.RECEIVE_BOOT_COMPLETED = 'ohos.permission.RECEIVE_BOOT_COMPLETED';
    this.SET_ALARM = 'ohos.permission.SET_ALARM';
    this.SET_TIME = 'ohos.permission.SET_TIME';
    this.SET_TIME_ZONE = 'ohos.permission.SET_TIME_ZONE';
    this.SET_WALLPAPER = 'ohos.permission.SET_WALLPAPER';
    this.STATUS_BAR = 'ohos.permission.SYSTEM_FLOAT_WINDOW'; // 状态栏相关
    this.SYSTEM_ALERT_WINDOW = 'ohos.permission.SYSTEM_FLOAT_WINDOW'; // 系统弹窗
    this.USE_SIP = 'ohos.permission.USE_SIP'; // SIP视频通话
    this.WRITE_SECURE_SETTINGS = 'ohos.permission.MANAGE_SECURE_SETTINGS'; // 安全设置
    this.WRITE_SETTINGS = 'ohos.permission.MANAGE_SYSTEM_SETTINGS'; // 系统设置

    // 以下为鸿蒙特有的权限
    this.DISTRIBUTED_DATASYNC = 'ohos.permission.DISTRIBUTED_DATASYNC'; // 分布式数据同步
    this.ACCESS_BIOMETRIC = 'ohos.permission.ACCESS_BIOMETRIC'; // 生物识别
    this.ACCESS_FACE_RECOGNITION = 'ohos.permission.ACCESS_FACE_RECOGNITION'; // 人脸识别
    this.ACCESS_FINGERPRINT = 'ohos.permission.ACCESS_FINGERPRINT'; // 指纹识别
    this.ACTIVITY_MOTION = 'ohos.permission.ACTIVITY_MOTION'; // 活动状态
    this.READ_HEALTH_DATA = 'ohos.permission.READ_HEALTH_DATA'; // 健康数据

    // 绑定服务相关权限
    this.BIND_APPWIDGET = 'NOT_AVAILABLE_IN_HARMONYOS'; // 鸿蒙中无小部件概念
    this.BIND_CARRIER_MESSAGING_SERVICE = 'NOT_AVAILABLE_IN_HARMONYOS'; // 运营商相关
    this.BIND_DREAM_SERVICE = 'NOT_AVAILABLE_IN_HARMONYOS'; // 屏保服务
    this.BIND_INPUT_METHOD = 'ohos.permission.MANAGE_INPUT_METHOD'; // 输入法管理
    this.BIND_NFC_SERVICE = 'ohos.permission.NFC'; // 合并到NFC权限
    this.BIND_NOTIFICATION_LISTENER_SERVICE = 'ohos.permission.NOTIFICATION_CONTROLLER'; // 通知管理
    this.BIND_PRINT_SERVICE = 'NOT_AVAILABLE_IN_HARMONYOS'; // 打印服务
    this.BIND_REMOTEVIEWS = 'NOT_AVAILABLE_IN_HARMONYOS'; // 远程视图
    this.BIND_TEXT_SERVICE = 'ohos.permission.MANAGE_INPUT_METHOD'; // 文本服务
    this.BIND_TV_INPUT = 'NOT_AVAILABLE_IN_HARMONYOS'; // TV输入
    this.BIND_VOICE_INTERACTION = 'ohos.permission.MANAGE_VOICE_KEY'; // 语音交互
    this.BIND_WALLPAPER = 'ohos.permission.SET_WALLPAPER'; // 壁纸设置
}

function deprecated(name) {
  console.warn("Calling cordova.plugins.permissions." + name + " with the successCallback as first argument is deprecated");
  console.warn("The new signature is '" + name + "(permission, successCallback, errorCallback)'");
}

Permissions.prototype = {
    checkPermission: function(permission, successCallback, errorCallback) {
        cordova.exec(successCallback, errorCallback, permissionsName, 'checkPermission', [permission]);
    },
    requestPermission: function(permission, successCallback, errorCallback) {
        if (typeof permission === "function") {
            deprecated("requestPermission");
            successCallback = arguments[0];
            errorCallback = arguments[1];
            permission = arguments[2];
        }
        cordova.exec(successCallback, errorCallback, permissionsName, 'requestPermission', [permission]);
    },
    requestPermissions: function(permissions, successCallback, errorCallback) {
        cordova.exec(successCallback, errorCallback, permissionsName, 'requestPermissions', permissions);
    }
};

Permissions.prototype.hasPermission = function (permission, successCallback, errorCallback) {
    console.warn("hasPermission() function deprecated. Considers using checkPermission()");

    if (typeof permission === "function") {
        deprecated("hasPermission");
        successCallback = arguments[0];
        errorCallback = arguments[1];
        permission = arguments[2];
    }
    this.checkPermission.call(this, permission, successCallback, errorCallback);
};

module.exports = new Permissions();

});
